@extends('layouts.app', ['activePage' => 'goods', 'titlePage' => __('商品管理')])

@section('content')
  <div class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <div class="card">
            <div class="card-header card-header-primary">
              <h4 class="card-title ">{{ __('商品列表') }}</h4>
            </div>
            <div class="card-body">
              @if (session('status'))
                <div class="row">
                  <div class="col-sm-12">
                    <div class="alert alert-success">
                      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <i class="material-icons">close</i>
                      </button>
                      <span>{{ session('status') }}</span>
                    </div>
                  </div>
                </div>
              @endif
              <div class="table-responsive">
                <table class="table">
                  <thead class="text-primary text-center">
                  <th>编号</th>
                  <th></th>
                  <th class="text-left">商品</th>
                  <th>分类</th>
                  <th>价格</th>
                  <th>更新时间</th>
                  <th>
                    <span>成交量
                        @if ($order=='desc')
                        <a href="goods?order=asc">↓</a>
                        @else
                        <a href="goods">↑</a>
                        @endif
                    </span>
                  </th>
                  <th>状态</th>
                  <th> 操作</th>
                  </thead>
                  <tbody>
                  @foreach($goods as $goods)
                    <tr class="text-center">
                      <td>
                        {{ $loop->iteration }}
                      </td>
                      <td class="text-right">
                        <img src="{{$goods->image_src}}"  data-toggle="modal" data-target="#goodsModel" style="width: 100px;cursor: pointer">
                      </td>
                      <td class="text-left">
                        {{ $goods->title }}
                        <div class="modal fade" id="goodsModel" tabindex="-1" role="dialog" aria-labelledby="goodsModelLabel" aria-hidden="true">
                            <div class="modal-dialog" role="document">
                              <div class="modal-content">
                                <div class="modal-header">
                                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                  </button>
                                </div>
                                <div class="modal-body">
                                    <img src="{{ $goods->image_src }}" class="mx-auto d-block" style="width: 100%">
                                </div>
                              </div>
                            </div>
                          </div>
                      </td>
                      <td>
                        {{ $goods->kind->name }}
                      </td>
                      <td>
                        {{$goods->price}}
                      </td>
                      <td>
                        {{ $goods->update_time }}
                      </td>
                      <td>
                        {{ $goods->order_count}}
                      </td>
                      <td>
                        @switch($goods->status)
                        @case('0') <span class="badge badge-pill badge-warning">未上架</span> @break
                        @case('1') <span class="badge badge-pill badge-success">已上架</span> @break
                        @endswitch
                      </td>
                      <td class="td-actions">
                        <button type="button" class="btn btn-danger" data-toggle="tooltip"  data-placement="top" title="移除该商品">
                          <i class="material-icons">close</i>
                        </button>
                      </td>
                    </tr>
                  @endforeach
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
@endsection
